/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package modele;

import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.swing.JComboBox;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;

/**
 *
 * @author merillot.dl02
 */
public class Sessions {

    private JComboBox lireXML() {

        JComboBox sessions = new JComboBox();
        SAXBuilder sxb = new SAXBuilder();

        try {
            Document document = sxb.build(new File("fichiers/sessions.xml"));
            Element racine = document.getRootElement();

            List<Element> listeSessions = racine.getChildren("site");
            for (Element site : listeSessions) {
                for (Element cursus : site.getChildren("cursus")) {
                    for (Element promotion : cursus.getChildren("promotion")) {
                        sessions.addItem(cursus.getAttributeValue("nom") + "-" + site.getAttributeValue("nom").substring(0, 1) + promotion.getText());
                    }
                }
            }
        } catch (JDOMException | IOException e) {

            System.err.println(e.getMessage());

        }
        return(sessions);
    }
}

//public void afficheEtudiant(){
//        
//        List <Element> listePromo =  this.racine.getChildren("promo");
//        
//        for(Element promo : listePromo){
//           
//            for(Element etudiant : promo.getChildren("edudiant")){
//                
//                System.out.println(etudiant.getAttributeValue("nom"));
//              
//                for(Element note : etudiant.getChildren()){
//                    
//                    System.out.println(note.getText());
//    }}}}
